﻿using DataWorks_Sqlite.MappingClass;
using DataWorks_Tools.BasicMethods;
using DataWorks_Tools.CleanDetails;
using DataWorks_Tools.MappModals;
using DataWorks_Tools.MappModals.UnifyModals;
using DataWorks_Tools.MatlabDetails;
using DataWorks_Tools.MergeDetails;
using DataWorks_Tools.SpikeDetails;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace DataWorks_Tools.ProcessExcute.Unify
{
    public class UnifyProcess
    {
        public static async Task<List<string>> UnifyProcessExcute(UnifyForOthersModals row)
        {
            var list = new List<string>();
            if (row.cleanmodal == null)
            {
                list.Add("清洗参数有问题");
                return list;
            }
            if (row.txtmergemodal1st == null)
            {
                list.Add("第一次txt合并参数有问题");
                return list;
            }
            if (row.spikemodal == null)
            {
                list.Add("毛刺修正参数有问题");
                return list;
            }
            if (row.predictmodal == null)
            {
                list.Add("预测参数有问题");
                return list;
            }
            if (row.txtmergemodal2ed == null)
            {
                list.Add("第二次txt合并参数有问题");
                return list;
            }
            if (row.ismultithreads == 1)
            {
                var cr = await CleanDetailsMethods.YXHExcuteCleanMultiThreadforUnifyAsync(row.cleanmodal);
                var m1r = await MergeDetailsMethods.YXHExcuteMergeMultiThreadAsync(row.txtmergemodal1st);
                var sr = await SpikeDetailsMethods.YXHExcuteSpikeMultiThreadsAsync(row.spikemodal);
                var dr = await ModalPredictionProcess.YXHExcuteDataPredictionMultiThreadLimitedAsync(row.predictmodal);
                var m2r = await MergeDetailsMethods.YXHExcuteMergeMultiThreadAsync(row.txtmergemodal2ed);
                list.AddRange(cr);
                list.AddRange(m1r);
                list.AddRange(sr);
                list.AddRange(dr);
                list.AddRange(m2r);
            }
            else
            {
                var cr = await CleanDetailsMethods.YXHExcuteCleanAsync(row.cleanmodal);
                var m1r = await MergeDetailsMethods.YXHExcuteMergeAsync(row.txtmergemodal1st);
                var sr = await SpikeDetailsMethods.YXHExcuteSpikeMultiThreadsAsync(row.spikemodal);
                var dr = await ModalPredictionProcess.YXHExcuteDataPredictionAsync(row.predictmodal);
                var m2r = await MergeDetailsMethods.YXHExcuteMergeAsync(row.txtmergemodal2ed);
                list.AddRange(cr);
                list.AddRange(m1r);
                list.AddRange(sr);
                list.AddRange(dr);
                list.AddRange(m2r);
            }
            return list;
        }
    }
}
